﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>菜牌灯箱-菜品图库</title>
    <link href="css/bootstrap.css" rel='stylesheet' type='text/css' />

    <link href="css/style.css" rel='stylesheet' type='text/css' />
    <meta name="viewport" content="width=device-width, initial-scale=1;charset=utf-8"">
   

    <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
     <script type="text/javascript" src="js/layer/layer.js"></script>
    <script type="text/javascript">
        var divshow;
        var showmtype = "菜品图库";
        var showstype = "所有分类";
        //var toptype = "";
        var whereadd = "";
        $(document).ready(function () {
            //layer.config({
            //    extend: 'extend/layer.ext.js'
            //});
            showmtype = getUrlParam2("mtype");
            showstype = getUrlParam2("stype");
           // toptype = getUrlParam2("toptype");
            if (showmtype == null) {
                showmtype = "菜品图库";
            }
            else
            {
                //<li><a href="products.html?mtype=1">菜牌灯箱</a></li>
                //            <li><a href="products.html?mtype=2">精品菜谱</a></li>
                //            <li><a href="products.html?mtype=3">菜品图库</a></li>
                //            <li><a href="products.html?mtype=4">专业摄影</a></li>
                //            <li><a href="products.html?mtype=5">商业展示灯箱</a></li>
                //            <li><a href="products.html?mtype=6">标牌标识</a></li>
                if (showmtype == "1")
                {
                    showmtype = "菜牌灯箱";
                }
                else if (showmtype == "2") {
                    showmtype = "精品菜谱";
                }
                else if (showmtype == "3") {
                    showmtype = "菜品图库";
                }
                else if (showmtype == "4") {
                    showmtype = "专业摄影";
                }
                else if (showmtype == "5") {
                    showmtype = "商业展示灯箱";
                }
                else if (showmtype == "6") {
                    showmtype = "标牌标识";
                }



            }
            if (showstype == null) {
                showstype = "所有分类";
            }
           // alert(showmtype + showstype);
            $("#showmtype").html(showmtype);
            $("#showstype").html(showstype);

            {

                var hcrainul = $("#hcrainul_fl");
                hcrainul.append("<li><a href=\"javascript:void(0)\" onclick=\"location.href=encodeURI('products.html?mtype=" + showmtype + "&stype=所有分类');\">所有分类</a></li>");
                //加载所有分类
                hcdosel("fv2", "table_sp", " type=2015111301 and fv3='" + showmtype + "'", "", "", "nv1 desc ", function (data) {
                    var objData = JSON.parse(data);
                    for (var i = 0; i < objData.length; i++) {
                        //  alert();
                     
                        hcrainul.append("<li><a href=\"javascript:void(0)\" onclick=\"location.href=encodeURI('products.html?mtype=" + showmtype + "&stype=" + objData[i].fv2 + "');\"> "+objData[i].fv2  +" </a></li>");
                    }
                });
            }
            //条件
            if (showstype == "所有分类") {
                whereadd = " savetype='files' and flb1='" + showmtype + "'";
            }
            else { whereadd =" savetype='files' and flb1='" + showmtype + "' and flb2='" + showstype + "'"; }
            divshow = $("#showimghcrain");
            divshow.text("");// 清空数据
            //运行
            demo();

            //layer.photosPage({
            //    parent: '#showimghcrain',
            //    title: '直接获取页面元素包含的所有图片',
            //    id: 112 //相册id，可选
            //});

            //layer.photos({
            //    photos: '#showimghcrain',
            //    area: ['1000px', '400px'], shift: 0, closeBtn: 1
            //});



        });
        var allimginfo = "";
        function showimg(id)
        {
  
            var jsonstring = "{\"title\": \"" + showmtype + "\",\"id\": 123,\"start\":" + id + ",\"data\":[" + allimginfo + "]}";
           // alert(jsonstring);
            var json = JSON.parse(jsonstring);
            //alert(json);
            layer.photos({
              
                //html: '这里传入自定义的html，也可以不传',
                photos: json,
                //area: ['1000px', '550px'],
                shift: -1,
                closeBtn: 1,
                moveOut: 0
            });

            //layer.closeAll();
            //layer.photos({
            //    photos: '#showimghcrain',
            //    area: ['1000px', '400px'], shift: 0, closeBtn: 1
            //});
          
            ////调用示例
            //layer.ready(function () { //为了layer.ext.js加载完毕再执行
            //    layer.photos({
            //        photos: '#showimghcrain',
            //        area: ['800px', '400px'], shift: 1, closeBtn: 1
            //    });
            //});


            //layer.photos({
            //    photos: json, //格式见API文档手册页 
            //    area: ['500px', '300px'], shift: 1, closeBtn: 1
            //    // tab: function(pic, layero){ 
            //    //$(".layui-layer-content .layui-layer-phimg").append("<div style=\"z-index:100000;height:80px;position:absolute;right:15px;top:15px;cursor:pointer; font-size:40px;font-weight:bold;\" onclick=\"javascript:layer.closeAll();\">x</div>"); 
            //    // } 
            //});



        }
        function find()
        {
            var findname = $("#findname").val();
            if (findname == "输入名称") findname="";
            //条件
            if (showstype == "所有分类") {
                whereadd = " savetype='files' and flb1='" + showmtype + "' and fimgname like '%" + findname + "%'";
            }
            else { whereadd = " savetype='files' and flb1='" + showmtype + "' and flb2='" + showstype + "' and fimgname like '%" + findname + "%'"; }
            demo();
        }
        function demo(curr) {
            layer.closeAll();
            allimginfo = "";
            $.ajax({
                type: "post",
                url: "../ashx/spui.ashx",
                data: {
                    "action": "getpageinfo",
                    "pagenow": curr || 1,
                    "pagesize": 25,
                    "select": "t.id,t.fimgname,t.fsaveurlmin,t.fsaveurl,t.flb3",
                    "table": "sysfileinfo as t",
                    "group": "",
                    "having": "",
                    "where": whereadd,
                    "order": ""
                },
                async: true,
                cache: false,
                error: function (error) {
                    // alert(error);
                },
                success: function (data) {
                    divshow.text("");// 清空数据
                    var testurl = "";
                    var result = JSON.parse(data);
                    // alert(result.message);
                    var objData = result.data;
                    var inow = 0;
                    var html = "";
                    var imgindex = -1;
                    for (var i = 0; i < objData.length; i++) {
                        var imgname = objData[i].fimgname;
                        var imgurlm = objData[i].fsaveurlmin;
                        var iurl = objData[i].fsaveurl;
                        inow++;
                        
                        if (objData[i].flb3 == 1) {
                            imgindex++;
                            //是图片
                            if (allimginfo.length == 0) allimginfo = "{\"alt\":\"" + imgname + "\",\"pid\": " + i + ",\"src\":\"" + iurl + "\",\"thumb\":\"" + imgurlm + "\" }";
                            else allimginfo += ",{\"alt\":\"" + imgname + "\",\"pid\": " + i + ",\"src\":\"" + iurl + "\",\"thumb\":\"" + imgurlm + "\" }";
                        }

                        if (inow == 1) {
                            if (objData[i].flb3 == 1) {
                                html = html + "<div class=\"product_box1\"><ul class=\"grid-4\"><li><a  href=\"javascript:void(0)\"  onclick=\"showimg('" + imgindex + "');\"><div class=\"view view-first\" style=\"text-align: left;\" ><img src=\"" + imgurlm + "\"   layer-src=" + iurl + "   class=\"img-responsive\" alt=\"" + imgname + "\" />" + imgname + "</div></a></li>";
                            }
                            else {
                                //非图片
                                html = html + "<div class=\"product_box1\"><ul class=\"grid-4\"><li><a  href=\"" + iurl + "\"  ><div class=\"view view-first\" style=\"text-align: left;\" >" + imgname + " 点击下载</div></a></li>";
                            }
                        }
                        else if (inow == 2 || inow == 3 || inow == 4) {
                            if (objData[i].flb3 == 1) {
                                html = html + "<li><a  href=\"javascript:void(0)\" onclick=\"showimg('" + imgindex + "');\">" +
                               "<div class=\"view view-first\" style=\"text-align: left;\" >" +
                                   "<img src=\"" + imgurlm + "\" layer-src=" + iurl + "   alt=\"" + imgname + "\" />" +
                                      "" + imgname + "" +
                               "</div>" +
                           "</a>" +
                           "</li>";
                            }
                            else {
                                //非图片
                                html = html + "<li><a  href=\"" + iurl + "\" >" +
                             "<div class=\"view view-first\" style=\"text-align: left;\" >" +
                                
                                    "" + imgname + " 点击下载" +
                             "</div>" +
                         "</a>" +
                         "</li>";
                            }
                        }
                        else {
                            if (objData[i].flb3 == 1) {
                                html = html + "<li class=\"grid-4_last\"><a  href=\"javascript:void(0)\" onclick=\"showimg('" + imgindex + "');\">" +
                                "<div class=\"view view-first\">" +
                                    "<img src=\"" + imgurlm + "\" layer-src=" + iurl + "  alt=\"" + imgname + "\" />" +
                                      "" + imgname + "" +
                                "</div>" +
                            "</a>" +
                            "</li>";
                            }

                            else {
                                //非图片
                                html = html + "<li class=\"grid-4_last\"><a  href=\"" + iurl + "\" >" +
                               "<div class=\"view view-first\">" +
                                     "" + imgname + " 点击下载" +
                               "</div>" +
                           "</a>" +
                           "</li>";
                            }

                            html = html + "<div class=\"clearfix\"></div></ul></div>";
                            inow = 0;

                        }

                    }
                    if (inow != 0) {
                        html = html + "<div class=\"clearfix\"></div></ul></div>";
                    }
                    divshow.append(html);
                    //显示分页
                    laypage({
                        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                        pages: result.message, //通过后台拿到的总页数
                        curr: curr || 1, //当前页
                        jump: function (obj, first) { //触发分页后的回调
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                                demo(obj.curr);
                            }
                        }
                    });
                    //var test = [{
                    //    "alt": "图片名4",
                    //    "pid": 666, //图片id
                    //    "src": testurl, //原图地址
                    //    "thumb": testurl //缩略图地址
                    //},
                    //{
                    //    "alt": "图片名",
                    //    "pid": 666, //图片id
                    //    "src": testurl, //原图地址
                    //    "thumb": testurl //缩略图地址
                    //}];
                    //var json = {
                    //    "title": "", //相册标题
                    //    "id": 123, //相册id
                    //    "start": 0, //初始显示的图片序号，默认0
                    //    "data":   //相册包含的图片，数组格式
                    //      test
                        
                    //};


                    //layer.photos({
                    //    photos: json,
                    //    area: ['1000px', '400px'], shift: 0, closeBtn: 1
                    //});



                    //layer.closeAll();

                   //layer.photos({
                   //     photos: '#showimghcrain',
                   //     area: ['1000px', '400px'], shift: 0, closeBtn: 1
                   //});
                

                    ////调用示例
                    //layer.ready(function () { //为了layer.ext.js加载完毕再执行
                    //    layer.photos({
                    //        photos: '#showimghcrain',
                    //        area: ['800px', '400px'], shift: 1, closeBtn: 1
                    //    });
                    //});





                }
            });




        };

        function getUrlParam2(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = (decodeURI(window.location.search)).substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
    </script>
</head>
<body>
    <div class="header">

        <div class="header_bottom">
            <div class="container">
                <div class="logo" style="color: #00CC00; font-size: 35px">
                    菜牌灯箱-图库大全
                </div>
                <div class="header_bottom_right">
                    <div class="h_menu4">
                        <!-- start h_menu4 -->
                        <a class="toggleMenu" href="#">Menu</a>
                        <ul class="nav">
                            <li class="active"><a href="hcrain.html">首页</a></li>
                            <li><a href="products.html?mtype=1">菜牌灯箱</a></li>
                            <li><a href="products.html?mtype=2">精品菜谱</a></li>
                            <li><a href="products.html?mtype=3">菜品图库</a></li>
                            <li><a href="products.html?mtype=4">专业摄影</a></li>
                            <li><a href="products.html?mtype=5">商业展示灯箱</a></li>
                            <li><a href="products.html?mtype=6">标牌标识</a></li>
                        </ul>

                    </div>
                    <!-- end h_menu4 -->

                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
    <ul class="breadcrumbs" style="background-color: #FF3300">
        <div class="container">
            <li class="home">
                <a href="hcrain.html" title="Go to Home Page">
                    <img src="images/home.png" alt="" /></a>
        <span></span>
            </li>
            <li class="home">
                <strong style="font-weight: bold; color: #000000">
                    <label id="showmtype"></label>
                    &nbsp; </strong>
                <span></span>
            </li>
            <li class="home">
                <span class="red"><label id="showstype" style="font-weight: bold; color: #0000CC"></label></span>
            </li>
        </div>
    </ul>
    
    <div class="products_top">
        <div class="container">
            <div class="col-md-2 product_left">
                <h1>分类</h1>
                <ul id="hcrainul_fl">
                </ul>


            </div>
            <div class="col-md-10">
                <div class="mens-toolbar login-right">
                    查找：<input type="text"  id=findname value="输入名称" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '输入名称';}" style="width: 30%;">
                    <a class="acount-btn" href="javascript:void(0)" onclick="find();" >查找</a>
                </div>
                <div id="showimghcrain">
                </div>
                <div class="pages">
                    <div id="page1" style="margin-top: 5px; text-align: center;"></div>
                    <br />

                    <div class="clearfix"></div>
                </div>
            </div>

        </div>
    </div>
<!--    <div class="grid-2">
        <div class="container">
        </div>
    </div>
    <div class="footer_top">
        <div class="container">
        </div>
    </div>-->
    <div class="footer_bottom" style="background-color:aliceblue;">
        <div class="container">

            <div style="text-align: center;" >
                <p >Copyright &copy; 2016.HCRain  All rights reserved.<a  href="http://www.hcrain.cn" target="_blank">追雨潮</a></p>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>

</body>
</html>
